//
//  ServeRecordCell.m
//  MerieuxWskProj
//
//  Created by MacBook Pro on 16/8/11.
//  Copyright © 2016年 visionet. All rights reserved.
//

#import "ServeRecordCell.h"
#import "ServeRecordArr.h"
#import "DevicePrepaireReportViewController.h"
#import "DevicePrepaireReportTwoViewController.h"
@implementation ServeRecordCell
@synthesize startTimeTF;
@synthesize endTimeTF;
@synthesize trafficTimeTF;
@synthesize ServeRecordArr;
@synthesize tableV;

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
+(instancetype)ServeRecordCellWithTableView:(UITableView *)tableView{
    static NSString *cellID = @"ServeRecordCell";
    ServeRecordCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    if (cell == nil) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"ServeRecordCell" owner:nil options:nil] lastObject];
    }
       
    return cell;

}

- (IBAction)add {
    if (self.indexPath.section == 4) {
        ServeRecordArr *arr= [[ServeRecordArr alloc]init];
        arr.startTime = startTimeTF.text;
        arr.endTime = endTimeTF.text;
        arr.trfficTime = trafficTimeTF.text;
        [self.parentController.serveRecordArr addObject:arr];
        NSLog(@" add   = =====%lu",self.parentController.serveRecordArr.count);
        [self.tableV reloadData];
    }else if (self.indexPath.section == 2) {
        ServeRecordArr *arr= [[ServeRecordArr alloc]init];
        arr.startTime = startTimeTF.text;
        arr.endTime = endTimeTF.text;
        arr.trfficTime = trafficTimeTF.text;
        [self.parentTwoController.serveRecordArr addObject:arr];
        NSLog(@"add ========%lu",self.parentTwoController.serveRecordArr.count);
        [self.tableV reloadData];
    }
    
}
- (IBAction)delete {
    if (self.indexPath.section == 4) {
        self.delBtn.hidden = NO;
        [self.parentController.serveRecordArr removeObjectAtIndex:self.indexPath.row-1];
       
        NSLog(@" add   = =====%lu",self.parentController.serveRecordArr.count);
        
        [self.tableV reloadData];
    }else if (self.indexPath.section == 2){
        self.delBtn.hidden = NO;
        [self.parentTwoController.serveRecordArr removeObjectAtIndex:self.indexPath.row - 1];
        
        NSLog(@" add   = =====%lu",self.parentTwoController.serveRecordArr.count);
        [self.tableV reloadData];

    }
    
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
